/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ivanhoe
 */
@Entity
@Table(name = "costos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Costos.findAll", query = "SELECT c FROM Costos c"),
    @NamedQuery(name = "Costos.findByIdCosto", query = "SELECT c FROM Costos c WHERE c.idCosto = :idCosto")})
public class Costos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_costo")
    private Integer idCosto;
    @ManyToMany(mappedBy = "costosCollection")
    private Collection<Proveedores> proveedoresCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "costos")
    private Collection<OrdenesTrabajoHasCostos> ordenesTrabajoHasCostosCollection;
    @JoinColumn(name = "id_tipo_costo", referencedColumnName = "id_tipo_costo")
    @ManyToOne(optional = false)
    private TipoCosto idTipoCosto;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "costosIdCosto")
    private Collection<DetallesCostos> detallesCostosCollection;

    public Costos() {
    }

    public Costos(Integer idCosto) {
        this.idCosto = idCosto;
    }

    public Integer getIdCosto() {
        return idCosto;
    }

    public void setIdCosto(Integer idCosto) {
        this.idCosto = idCosto;
    }

    @XmlTransient
    public Collection<Proveedores> getProveedoresCollection() {
        return proveedoresCollection;
    }

    public void setProveedoresCollection(Collection<Proveedores> proveedoresCollection) {
        this.proveedoresCollection = proveedoresCollection;
    }

    @XmlTransient
    public Collection<OrdenesTrabajoHasCostos> getOrdenesTrabajoHasCostosCollection() {
        return ordenesTrabajoHasCostosCollection;
    }

    public void setOrdenesTrabajoHasCostosCollection(Collection<OrdenesTrabajoHasCostos> ordenesTrabajoHasCostosCollection) {
        this.ordenesTrabajoHasCostosCollection = ordenesTrabajoHasCostosCollection;
    }

    public TipoCosto getIdTipoCosto() {
        return idTipoCosto;
    }

    public void setIdTipoCosto(TipoCosto idTipoCosto) {
        this.idTipoCosto = idTipoCosto;
    }

    @XmlTransient
    public Collection<DetallesCostos> getDetallesCostosCollection() {
        return detallesCostosCollection;
    }

    public void setDetallesCostosCollection(Collection<DetallesCostos> detallesCostosCollection) {
        this.detallesCostosCollection = detallesCostosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCosto != null ? idCosto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Costos)) {
            return false;
        }
        Costos other = (Costos) object;
        if ((this.idCosto == null && other.idCosto != null) || (this.idCosto != null && !this.idCosto.equals(other.idCosto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Costos[ idCosto=" + idCosto + " ]";
    }
    
}
